package com.binance.masterelection.condition;

import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;
//用来判断当前环境是不是springcloud微服务环境
public class SpringCloudCondition implements Condition {
    @Override
    public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
        String applcationName = conditionContext.getEnvironment().getProperty("spring.application.name");
        if (StringUtils.isBlank(applcationName)) {
            return false;
        } else {
            return true;
        }
    }
}
